<?php 
include_once "User.php";
	class Administrador extends User
	{
	
		public $CPF;
		
		//login tava como o nome
		public static function cadastraAdmin($var_name, $var_cpf, $var_password, $var_login, $var_sex)
		{
			include "ConnectBD.php";
			$procedure = ("call cadastrar_administrador('". $var_cpf ."', '". $var_password ."', '". $var_login ."', '". $var_name ."', '". $var_sex ."')");
			$query = mysql_query($procedure, $id);
			mysql_close($id);
			if(!$query)
			{
				return false;
			}
			else
			{				
				return true;
			}		
		}	
		
		public static function updateAdmin($varidAdmin, $var_name, $var_login, $var_cpf, $var_password, $var_sex)
		{
			include "ConnectBD.php";
			$procedure = ("call editar_administrador('". $varidAdmin ."', '". $var_cpf ."', '". $var_login ."', '". $var_password ."', '". $var_name ."', '". $var_sex ."')");
			$query = mysql_query($procedure, $id);
			mysql_close($id);
			if(!$query)
			{
				return false;
			}
			else
			{				
				return true;
			}		
		}	
		
		
		public static function getAdministrador($id_admin)
		{
			include "ConnectBD.php";
			$query = mysql_query("select pe.cpf, pe.nome as nome, pe.sexo, pe.senha, pe.login
									from Pessoa pe 
									inner join Administrador ad
									on pe.cpf = ad.cpf_adm
									where 
									ad.cpf_adm = '".$id_admin. "' ", $id);
			
			if(mysql_num_rows($query)> 0)
			{
				$administrador = new Administrador();
				$administrador->CPF = mysql_result($query, 0, "cpf");
				$administrador->Name = mysql_result($query, 0, "nome");
				$administrador->Gender = mysql_result($query, 0, "sexo");
				$administrador->Password = mysql_result($query, 0, "senha");
				$administrador->Login = mysql_result($query, 0, "login");
				
				return $administrador;
			}			
			
		}	
		
	}
?>